<template>
	<view class="list-view">
		<view class="top-bar"><uni-navbar :fixed="true" :back="true" color="#fff" title="会议发言"></uni-navbar></view>

		<view class="u-line"></view>
		<u-row class="link-box" gutter="0" align="top">
			<u-col span="3" v-if="$sysMenus('hyfy_top_add')">
				<navigator hover-class="none" class="link-item" url="/pagesB/speech/add">
					<image src="/static/img/icon_79.png" mode="aspectFill"></image>
					提交发言
				</navigator>
			</u-col>
			<u-col span="3">
				<navigator hover-class="none" class="link-item" url="/pagesB/speech/list">
					<image src="/static/img/icon_80.png" mode="aspectFill"></image>
					会议发言
				</navigator>
			</u-col>
			<u-col span="3" v-if="$sysMenus('hyfy_top_draft')">
				<navigator hover-class="none" class="link-item" url="/pagesB/speech/spare_list?status=0">
					<image src="/static/img/icon_81.png" mode="aspectFill"></image>
					草稿箱
				</navigator>
			</u-col>
		</u-row>

		<view class="list-box">
			<view class="filter-inner">
				<view class="filter-btn" :class="filterType == 0 ? 'active' : ''" @click="type(0)" v-if="$sysMenus('hyfy_top_list')">
					<image src="/static/img/icon_11.png" mode="widthFix"></image>
					<image src="/static/img/icon_11_f.png" mode="widthFix"></image>
					我的会议发言
				</view>
				<view class="filter-btn" :class="filterType == 1 ? 'active' : ''" @click="type(1)" v-if="$sysMenus('hyfy_top_list_all')">
					<image src="/static/img/icon_10.png" mode="widthFix"></image>
					<image src="/static/img/icon_10_f.png" mode="widthFix"></image>
					所有会议发言
				</view>
			</view>

			<view class="list-info_02" v-for="(item, index) of speechList" :key="item.id" @click="navTo(item)">
				<view class="left">
					<view class="info-title">{{ item.title }}</view>
					<view class="info-btm">{{ item.createTime | parseTime('{y}-{m}-{d}') }}</view>
				</view>
				<view class="right" :class="[index % 2 == 0 ? 'bg1' : 'bg2']">会议发言</view>
			</view>
			<u-loadmore :status="loading" />
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	data() {
		return {
			numAll: 0,
			num2: 0,
			num5: 0,
			filterType: 0,
			keyword: '',
			speechList: [],

			hyfy: {
				clientCode: '',
				jieId: '',
				ciId: '',
				title: '',
				classification: '',
				submitTime: '',
				type: '',
				conferenceType: ''
			},
			loading: 'loadmore'
		};
	},
	onLoad() {
		this.loadLogin();
		this.loadData();
	},
	onPullDownRefresh() {
		this.loadData('refresh');
	},
	onReachBottom() {
		if (this.loading == 'loadmore') this.loadData('add');
	},
	computed: {
		...mapState(['userInfo'])
	},
	methods: {
		loadLogin() {
			if (this.userInfo.Authorization) {
				this.hyfy.clientCode = this.userInfo.sysUser.clientCode;
				this.userId = this.userInfo.sysUser.id;
				this.roleCodes = this.userInfo.roleCodes.join(',');

				this.pageNum = 1;
				this.pageSize = 10;
			} else {
				this.$logout();
			}
		},
		loadData(type = 'add') {
			if (this.loading == 'loading') {
				return false;
			}
			if (type == 'add') {
				if (this.loading == 'nomore') {
					return false;
				}
				this.loading = 'loading';
			} else {
				this.loading = 'loading';
			}
			if (type != 'add') {
				this.pageNum = 1;
			}
			let data = {
				pageNum: this.pageNum,
				pageSize: this.pageSize,
				currentUserId: this.userId,
				roleCodes: this.roleCodes,
				conferenceSpeech: this.hyfy
			};
			let url = '/huiyifayan/conference-speech/list';
			if (this.filterType == 0) {
				url = '/huiyifayan/conference-speech/myselflist';
				if (this.$roleCodes('fydw')) {
					data.remark1 = this.userInfo.sysUser.remark1;
				}
			}

			this.$request(url, data, {
				load: true
			}).then((res) => {
				let count = 0;
				if (type != 'add') {
					uni.stopPullDownRefresh();
					this.speechList = [];
				}
				this.loading = this.pageNum < Math.ceil(res.data.total / this.pageSize) ? 'loadmore' : 'nomore';
				this.pageNum = this.pageNum + 1;
				this.speechList = this.speechList.concat(res.data.records);
				this.loaded = true;
				if (this.speechList.length <= 0) {
					this.loading = 'nodata';
				}
			});
		},
		search(e) {
			this.keyword = e;
			this.loadData('refresh');
		},
		type(e) {
			this.filterType = e;
			this.loadData('refresh');
		},
		navTo(item) {
			if (!this.userInfo) {
				this.$logout();
			} else {
				uni.navigateTo({
					url: '/pagesB/speech/detail?id=' + item.id
				});
			}
		}
	}
};
</script>

<style lang="scss">
.list-box {
	margin-bottom: 30rpx;
	padding: 30rpx 30rpx 0;
	background-color: #fff;
}

.list-info_02 .right {
	width: 236rpx;
	height: 148rpx;
	font-size: 17px;
	color: #fff;
	line-height: 148rpx;
	text-align: center;
	background: #e5231a no-repeat center;
	background-size: 100%;
	text-shadow: rgba(0, 0, 0, 0.4) 0em 0.12em 0.2em;
	letter-spacing: 2px;
}
</style>
